package com.read.service.impl;

import com.read.service.MailService;
import com.read.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 * @author sh-sunb6
 * @description 邮箱服务实现类
 * @date 2019-02-22 14:16
 */
@Service
public class MailServiceImpl implements MailService {

    private static final Logger logger = LoggerFactory.getLogger(MailServiceImpl.class);

    @Autowired
    private JavaMailSender mailSender;

    @Override
    public void sendMail(String from, String to, String content) {
        String contentMsg = "您好，您的邮箱验证码为：" + content + "，10分钟之内有效，请勿告诉他人！";

        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(from);  //发送者
        message.setTo(to);  //邮件发送给谁
        message.setSubject("博阅吧邮箱验证码");
        message.setText(contentMsg);
        mailSender.send(message);
    }
}
